package com.njust.service;

import com.njust.dao.BookDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class BookService {

    @Autowired
    private BookDao bookDao;

    //没有指定name和type,先按照变量名进行匹配，没有然后按照变量类型匹配，没有或有多个抛异常
    //如果指定name，只会按照name匹配
    @Resource
    private BookDao bookDao1;

    public void save(){
        System.out.println("BookService正在调用bookDao帮你保存图书");
        bookDao.saveBook();
    }

    public void test(){
        System.out.println("bookDao = " + bookDao);
        System.out.println("bookDao1 = " + bookDao1);
    }
}
